﻿//Writer类的基类，供Ext.data.ServerProxy的大多数子类使用。
Ext.data.Writer = Ext.extend(Object, {

    constructor: function (config) {
        Ext.apply(this, config);
    },

    // 将请求数据以正确形式写入Ext.data.Request对象request
    write: function (request) {
        var operation = request.operation,
            records = operation.records || [],
            ln = records.length,
            i = 0,
            data = [];

        //把记录集合的记录装进数组
        for (; i < ln; i++) {
            data.push(this.getRecordData(records[i]));
        }
        return this.writeRecords(request, data); //将记录赋给request，由子类实现
    },


    getRecordData: function (record) {
        return record.data;
    }
});

Ext.data.WriterMgr.registerType('base', Ext.data.Writer);